home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 October: Mac OS SDK / Dev.CD Oct 97 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Universal / Interfaces / CIncludes / Translation.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-08-12  |  12.0 KB  |  326 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        Translation.h
  3.  
  4.      Contains:    Translation Manager (Macintosh Easy Open) Interfaces.
  5.  
  6.      Version:    Technology:    Macintosh Easy Open 1.1
  7.                  Release:    Universal Interfaces 3.0.1
  8.  
  9.      Copyright:    © 1991-1997 by Apple Computer, Inc., all rights reserved.
  10.  
  11.      Bugs?:        Please include the the file and version information (from above) with
  12.                  the problem description.  Developers belonging to one of the Apple
  13.                  developer programs can submit bug reports to:
  14.  
  15.                      devsupport@apple.com
  16.  
  17. */
  18. #ifndef __TRANSLATION__
  19. #define __TRANSLATION__
  20.  
  21. #ifndef __TYPES__
  22. #include <Types.h>
  23. #endif
  24. #ifndef __FILES__
  25. #include <Files.h>
  26. #endif
  27. #ifndef __COMPONENTS__
  28. #include <Components.h>
  29. #endif
  30. #ifndef __TRANSLATIONEXTENSIONS__
  31. #include <TranslationExtensions.h>
  32. #endif
  33.  
  34.  
  35.  
  36. #if PRAGMA_ONCE
  37. #pragma once
  38. #endif
  39.  
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43.  
  44. #if PRAGMA_IMPORT
  45. #pragma import on
  46. #endif
  47.  
  48. #if PRAGMA_STRUCT_ALIGN
  49.     #pragma options align=mac68k
  50. #elif PRAGMA_STRUCT_PACKPUSH
  51.     #pragma pack(push, 2)
  52. #elif PRAGMA_STRUCT_PACK
  53.     #pragma pack(2)
  54. #endif
  55.  
  56. /* enumerated types on how a document can be opened*/
  57. typedef short                             DocOpenMethod;
  58.  
  59. enum {
  60.     domCannot                    = 0,
  61.     domNative                    = 1,
  62.     domTranslateFirst            = 2,
  63.     domWildcard                    = 3
  64. };
  65.  
  66. /* 0L terminated array of OSTypes, or FileTypes*/
  67. typedef OSType                             TypesBlock[64];
  68. typedef OSType *                        TypesBlockPtr;
  69. /* Progress dialog resource ID*/
  70.  
  71. enum {
  72.     kTranslationScrapProgressDialogID = -16555
  73. };
  74.  
  75. /* block of data that describes how to translate*/
  76. struct FileTranslationSpec {
  77.     OSType                             componentSignature;
  78.     const void *                    translationSystemInfo;
  79.     FileTypeSpec                     src;
  80.     FileTypeSpec                     dst;
  81. };
  82. typedef struct FileTranslationSpec FileTranslationSpec;
  83.  
  84. typedef FileTranslationSpec *            FileTranslationSpecArrayPtr;
  85. /*****************************************************************************************
  86. *   GetFileTypesThatAppCanNativelyOpen
  87. *  This routine returns a list of all FileTypes that an application can open by itself
  88. *  Enter:    appVRefNumHint        volume where application resides (can be wrong, and if is, will be used as a starting point)
  89. *             appSignature        signature (creator) of application
  90. *             nativeTypes            pointer to a buffer to be filled with up to 64 FileTypes
  91. *  Exit:    nativeTypes            zero terminated array of FileTypes that can be opened by app
  92. */
  93. EXTERN_API( OSErr )
  94. GetFileTypesThatAppCanNativelyOpen (short                 appVRefNumHint,
  95.                                  OSType                 appSignature,
  96.                                  FileType *                nativeTypes)                        TWOWORDINLINE(0x701C, 0xABFC);
  97.  
  98. /*****************************************************************************************
  99. *  ExtendFileTypeList
  100. *  This routine makes a new list of file types that can be translated into a type in the given list
  101. *  Used by StandardFile
  102. *  Enter:    originalTypeList        pointer to list of file types that can be opened
  103. *             numberOriginalTypes        number of file types in orgTypeList
  104. *              extendedTypeList        pointer to a buffer to be filled with file types
  105. *             numberExtendedTypes        max number of file types that can be put in extendedTypeList
  106. *  Exit:    extendedTypeList        buffer filled in with file types that can be translated
  107. *             numberExtendedTypes        number of file types put in extendedTypeList
  108. */
  109. EXTERN_API( OSErr )
  110. ExtendFileTypeList                (const FileType *        originalTypeList,
  111.                                  short                     numberOriginalTypes,
  112.                                  FileType *                extendedTypeList,
  113.                                  short *                numberExtendedTypes)                TWOWORDINLINE(0x7009, 0xABFC);
  114.  
  115.  
  116. /*****************************************************************************************
  117. *  This routine checks if a file can be opened by a particular application.
  118. *  If so, it returns if it needs to be translated first, and if so then how.
  119. *  The FileTypes that the app can open are specified by nativelyOpenableTypes,
  120. *  or if it is NULL, GetFileTypesThatAppCanNativelyOpen is called.
  121. *  Enter:    targetDocument        document to check if it can be opened
  122. *             appVRefNumHint        vRefNum of application to open doc ( can be wrong, and if is, will be used as a starting point)
  123. *             appSignature        signature (creator) of application to open doc
  124. *             nativeTypes            zero terminated list of FileTypes app can open natively, or NULL to use default list
  125. *             onlyNative            whether to consider if document can be translated before opening
  126. *             howToOpen            pointer to buffer in which to put how the document can be opened
  127. *             howToTranslate        pointer to buffer in which to put a FileTranslationSpec record
  128. *  Exit:    howToOpen            whether file needs to be translated to be read
  129. *             howToTranslate        if file can be translated, buffer filled in with how to translate
  130. *             returns                noErr, noPrefAppErr
  131. */
  132. EXTERN_API( OSErr )
  133. CanDocBeOpened                    (const FSSpec *            targetDocument,
  134.                                  short                     appVRefNumHint,
  135.                                  OSType                 appSignature,
  136.                                  const FileType *        nativeTypes,
  137.                                  Boolean                 onlyNative,
  138.                                  DocOpenMethod *        howToOpen,
  139.                                  FileTranslationSpec *    howToTranslate)                        TWOWORDINLINE(0x701E, 0xABFC);
  140.  
  141.  
  142. /*****************************************************************************************
  143. *  GetFileTranslationPaths
  144. *  This routine returns a list of all ways a translation can occure to or from a FileType.
  145. *  The app is checked to exist.  The hint for each app is the VRefNum and DTRefNum
  146. *  Enter:    srcDoc            source file or NULL for all matches
  147. *             dstDoc            destination FileType or NULL for all matches
  148. *             maxResultCount
  149. *             resultBuffer
  150. *  Exit:    number of paths
  151. */
  152. EXTERN_API( short )
  153. GetFileTranslationPaths            (FSSpec *                srcDocument,
  154.                                  FileType                 dstDocType,
  155.                                  unsigned short         maxResultCount,
  156.                                  FileTranslationSpecArrayPtr  resultBuffer)                    TWOWORDINLINE(0x7038, 0xABFC);
  157.  
  158. /*****************************************************************************************
  159. *  GetPathFromTranslationDialog
  160. *  This routine, with a given document, application, and a passed typelist will display the
  161. *  Macintosh Easy Open translation dialog allowing the user to make a choice.  The choice
  162. *  made will be written as a preference (so the next call to CanDocBeOpened() will work).
  163. *  The routine returns the translation path information.
  164. *  Enter:    theDocument            FSSpec to document to open
  165. *             theApplication        FSSpec to application to open document
  166. *             typeList            Nil terminated list of FileType's (e.g. SFTypeList-like) of types
  167. *                                 you would like the documented translated to.  Order most perferred
  168. *                                 to least.
  169. *  Exit:    howToOpen            Translation method needed to open document
  170. *             howToTranslate        Translation specification
  171. *             returns                Any errors that might occur.
  172. */
  173. EXTERN_API( OSErr )
  174. GetPathFromTranslationDialog    (const FSSpec *            theDocument,
  175.                                  const FSSpec *            theApplication,
  176.                                  TypesBlockPtr             typeList,
  177.                                  DocOpenMethod *        howToOpen,
  178.                                  FileTranslationSpec *    howToTranslate)                        TWOWORDINLINE(0x7037, 0xABFC);
  179.  
  180.  
  181. /*****************************************************************************************
  182. *   TranslateFile
  183. *  This routine reads a file of one format and writes it to another file in another format. 
  184. *  The information on how to translated is generated by the routine CanDocBeOpened.
  185. *  TranslateFile calls through to the TranslateFile Extension's DoTranslateFile routine.  
  186. *  The destination file must not exist.  It is created by this routine.  
  187. *  Enter:    sourceDocument            input file to translate
  188. *             destinationDocument        output file of translation
  189. *             howToTranslate            pointer to info on how to translate
  190. *  Exit:    returns                    noErr, badTranslationSpecErr 
  191. */
  192. EXTERN_API( OSErr )
  193. TranslateFile                    (const FSSpec *            sourceDocument,
  194.                                  const FSSpec *            destinationDocument,
  195.                                  const FileTranslationSpec * howToTranslate)                TWOWORDINLINE(0x700C, 0xABFC);
  196.  
  197. /*****************************************************************************************
  198. *   GetDocumentKindString
  199. *  This routine returns the string the Finder should show for the "kind" of a document
  200. *  in the GetInfo window and in the kind column of a list view.  
  201. *  Enter:    docVRefNum        The volume containing the document
  202. *             docType            The catInfo.fdType of the document
  203. *             docCreator        The catInfo.fdCreator of the document
  204. *             kindString        pointer to where to return the string
  205. *  Exit:    kindString        pascal string.  Ex: "\pSurfCalc spreadsheet"
  206. *             returns            noErr, or afpItemNoFound if kind could not be determined
  207. */
  208. EXTERN_API( OSErr )
  209. GetDocumentKindString            (short                     docVRefNum,
  210.                                  OSType                 docType,
  211.                                  OSType                 docCreator,
  212.                                  Str63                     kindString)                            TWOWORDINLINE(0x7016, 0xABFC);
  213.  
  214. /*****************************************************************************************
  215. *  GetTranslationExtensionName
  216. *  This routine returns the translation system name from a specified TranslationSpec
  217. *  Enter:    translationMethod    The translation path to get the translation name from
  218. *  Exit:    extensionName        The name of the translation system
  219. *             returns                Any errors that might occur
  220. */
  221. EXTERN_API( OSErr )
  222. GetTranslationExtensionName        (const FileTranslationSpec * translationMethod,
  223.                                  Str31                     extensionName)                        TWOWORDINLINE(0x7036, 0xABFC);
  224.  
  225.  
  226. /*****************************************************************************************
  227. *  GetScrapDataProcPtr
  228. *  This is a prototype for the function you must supply to TranslateScrap. It is called to 
  229. *  get the data to be translated.  The first call TranslateScrap will make to this is to
  230. *  ask for the 'fmts' data.  That is a special.   You should resize and fill in the handle
  231. *  with a list all the formats that you have available to be translated, and the length of each.
  232. *  (See I.M. VI 4-23 for details of 'fmts').  It will then be called again asking for one of  
  233. *  the formats that 'fmts' list said was available.
  234. *  Enter:    requestedFormat            Format of data that TranslateScrap needs.
  235. *             dataH                    Handle in which to put the requested data
  236. *             srcDataGetterRefCon        Extra parameter for you passed to TranslateScrap
  237. *             
  238. *  Exit:    dataH                    Handle is resized and filled with data in requested format
  239. */
  240. typedef CALLBACK_API( OSErr , GetScrapDataProcPtr )(ScrapType requestedFormat, Handle dataH, void *srcDataGetterRefCon);
  241. typedef STACK_UPP_TYPE(GetScrapDataProcPtr)                     GetScrapDataUPP;
  242. enum { uppGetScrapDataProcInfo = 0x00000FE0 };                     /* pascal 2_bytes Func(4_bytes, 4_bytes, 4_bytes) */
  243. #define NewGetScrapDataProc(userRoutine)                         (GetScrapDataUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppGetScrapDataProcInfo, GetCurrentArchitecture())
  244. #define CallGetScrapDataProc(userRoutine, requestedFormat, dataH, srcDataGetterRefCon)  CALL_THREE_PARAMETER_UPP((userRoutine), uppGetScrapDataProcInfo, (requestedFormat), (dataH), (srcDataGetterRefCon))
  245. typedef GetScrapDataUPP                 GetScrapData;
  246. /*****************************************************************************************
  247. *  TranslateScrap
  248. *  This routine resizes the destination handle and fills it with data of the requested format.
  249. *  The data is generated by translated one or more source formats of data supplied by
  250. *  the procedure srcDataGetter.  
  251. *  This routine is automatically called by GetScrap and ReadEdition.  You only need to call
  252. *  this if you need to translated scrap style data, but are not using the ScrapMgr or EditionMgr.
  253. *  Enter:    sourceDataGetter            Pointer to routine that can get src data
  254. *             sourceDataGetterRefCon        Extra parameter for dataGetter
  255. *             destinationFormat            Format of data desired
  256. *             destinationData                Handle in which to store translated data
  257. *             
  258. *  Exit:    dstData                        Handle is resized and filled with data in requested format
  259. */
  260. EXTERN_API( OSErr )
  261. TranslateScrap                    (GetScrapData             sourceDataGetter,
  262.                                  void *                    sourceDataGetterRefCon,
  263.                                  ScrapType                 destinationFormat,
  264.                                  Handle                 destinationData,
  265.                                  short                     progressDialogID)                    TWOWORDINLINE(0x700E, 0xABFC);
  266.  
  267.  
  268.  
  269.  
  270. #if PRAGMA_STRUCT_ALIGN
  271.     #pragma options align=reset
  272. #elif PRAGMA_STRUCT_PACKPUSH
  273.     #pragma pack(pop)
  274. #elif PRAGMA_STRUCT_PACK
  275.     #pragma pack()
  276. #endif
  277.  
  278. #ifdef PRAGMA_IMPORT_OFF
  279. #pragma import off
  280. #elif PRAGMA_IMPORT
  281. #pragma import reset
  282. #endif
  283.  
  284. #ifdef __cplusplus
  285. }
  286. #endif
  287.  
  288. #endif /* __TRANSLATION__ */
  289.  
  290.